package com.cleaningcloud.cld.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.cleaningcloud.cld.domain.vo.CldRevisitVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cleaningcloud.common.log.annotation.Log;
import com.cleaningcloud.common.log.enums.BusinessType;
import com.cleaningcloud.common.security.annotation.RequiresPermissions;
import com.cleaningcloud.cld.domain.CldRevisit;
import com.cleaningcloud.cld.service.ICldRevisitService;
import com.cleaningcloud.common.core.web.controller.BaseController;
import com.cleaningcloud.common.core.web.domain.AjaxResult;
import com.cleaningcloud.common.core.utils.poi.ExcelUtil;
import com.cleaningcloud.common.core.web.page.TableDataInfo;

/**
 * 回访信息Controller
 * 
 * @author cleaningcloud
 * @date 2025-06-12
 */
@RestController
@RequestMapping("/revisit")
public class CldRevisitController extends BaseController
{
    @Autowired
    private ICldRevisitService cldRevisitService;

    /**
     * 查询回访信息列表
     */
    @RequiresPermissions("cld:revisit:list")
    @GetMapping("/list")
    public TableDataInfo list(CldRevisitVo cldRevisitVo)
    {
        startPage();
        List<CldRevisitVo> list = cldRevisitService.selectCldRevisitList(cldRevisitVo);
        return getDataTable(list);
    }

    /**
     * 导出回访信息列表
     */
    @RequiresPermissions("cld:revisit:export")
    @Log(title = "回访信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CldRevisitVo cldRevisitVo)
    {
        List<CldRevisitVo> list = cldRevisitService.selectCldRevisitList(cldRevisitVo);
        ExcelUtil<CldRevisitVo> util = new ExcelUtil<CldRevisitVo>(CldRevisitVo.class);
        util.exportExcel(response, list, "回访信息数据");
    }

    /**
     * 获取回访信息详细信息
     */
    @RequiresPermissions("cld:revisit:query")
    @GetMapping(value = "/{revisitId}")
    public AjaxResult getInfo(@PathVariable("revisitId") Long revisitId)
    {
        return success(cldRevisitService.selectCldRevisitByRevisitId(revisitId));
    }

    /**
     * 新增回访信息
     */
    @RequiresPermissions("cld:revisit:add")
    @Log(title = "回访信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CldRevisit cldRevisit)
    {
        return toAjax(cldRevisitService.insertCldRevisit(cldRevisit));
    }

    /**
     * 修改回访信息
     */
    @RequiresPermissions("cld:revisit:edit")
    @Log(title = "回访信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CldRevisit cldRevisit)
    {
        return toAjax(cldRevisitService.updateCldRevisit(cldRevisit));
    }

    /**
     * 删除回访信息
     */
    @RequiresPermissions("cld:revisit:remove")
    @Log(title = "回访信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{revisitIds}")
    public AjaxResult remove(@PathVariable Long[] revisitIds)
    {
        return toAjax(cldRevisitService.deleteCldRevisitByRevisitIds(revisitIds));
    }
}
